﻿using System;

namespace Quicklight.Web.Razor {

   /// <summary>
   /// A Binder class performs the actual binding declared by a declarative binding method. It is able to create an element locator that can be inserted
   /// into the HTML markup so that the element is locatable in the DOM for binding.
   /// </summary>
   public abstract class Binder {

      /// <summary>
      /// This method is called by a declarative binding method to get a element locator to insert into the HTML
      /// </summary>
      /// <param name="key">Unique key for this binder</param>
      /// <returns>Element locator string to insert into the HTML</returns>
      public abstract string GetElementLocator(string key);

      /// <summary>
      /// The Bind method does the actual binding. It locates the element by way of the element locator, gives it an id it it does not have one, binds the element
      /// and removes the element locator.
      /// </summary>
      /// <param name="key">Unique key for this binder</param>
      public abstract void Bind(string key);

   }
}
